﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Ivy.Common.Framework.Base;
using Ivy.UserRegistration.Entity;



namespace HSMPWeb.UserControls
{
    public partial class ListingControl : System.Web.UI.UserControl
    {
        #region  Variable & constant
        List<DataEntityBase> lDataCollection = new List<DataEntityBase>();
        string lColumnCaptionHeading = string.Empty;
        string lUniqueRecordIdentifierAttribute = string.Empty;
        int lTotalRecordCount = 0;
        int lTotalRecordDisplayPerPage = -1;
        int lGetCurrentDisplayPageNo = 0;
        bool lIsAddNewVisible = true;
        bool lIsEditVisible = true;
        bool lIsDeleteVisible = true;
        bool lIsViewDetailsVisible = true;
        List<BoundField> lBoundGridFields = null;

        //string lViewDetailsAction = string.Empty;
        #endregion  Variable & constant

        #region Constructor & Destructor
        #endregion Constructor & Destructor

        #region Properties
        public Object DataCollection
        {
            get
            {
                return this.gdvListGrid.DataSource;
                //lDataCollection = (List<DataEntityBase>) this.gdvListGrid.DataSource;
                //return lDataCollection;
            }
            set
            {
                this.gdvListGrid.DataSource = value;
                //lDataCollection = value;
                //this.gdvListGrid.DataSource = lDataCollection;
            }
        }

        public string ColumnCaptionHeading
        {
            get
            {
                return lColumnCaptionHeading;
            }
            set
            {
                lColumnCaptionHeading = value;
            }
        }

        public string UniqueRecordIdentifierAttribute
        {
            get
            {
                return lUniqueRecordIdentifierAttribute;
            }
            set
            {
                lUniqueRecordIdentifierAttribute = value;
            }
        }

        public int TotalRecordCount
        {
            get
            {
                return lTotalRecordCount;
            }
            set
            {
                lTotalRecordCount = value;
            }
        }

        public int TotalRecordDisplayPerPage
        {
            get
            {
                return lTotalRecordDisplayPerPage;
            }
            set
            {
                lTotalRecordDisplayPerPage = value;
            }
        }

        public int GetCurrentDisplayPageNo
        {
            get
            {
                return lGetCurrentDisplayPageNo;
            }
            set
            {
                lGetCurrentDisplayPageNo = value;
            }
        }

        public bool IsAddNewVisible
        {
            get
            {
                return lIsAddNewVisible;
            }
            set
            {
                lIsAddNewVisible = value;
            }
        }

        public bool IsEditVisible
        {
            get
            {
                return lIsEditVisible;
            }
            set
            {
                lIsEditVisible = value;
            }
        }

        public bool IsDeleteVisible
        {
            get
            {
                return lIsDeleteVisible;
            }
            set
            {
                lIsDeleteVisible = value;
            }
        }

        public bool IsViewDetailsVisible
        {
            get
            {
                return lIsViewDetailsVisible;
            }
            set
            {
                lIsViewDetailsVisible = value;
            }
        }

        #endregion Properties

        #region Public Methods
        public List<DataEntityBase> GetDataCollection()
        {
            throw new NotImplementedException();
        }

        public void ClearGrid()
        {
            this.gdvListGrid.DataSource = null;
            this.gdvListGrid.DataBind();
        }

        public void RefreshGrid()
        {
            this.gdvListGrid.DataBind();
        }

        public void LoadGridData()
        {
            if (this.DataCollection != null)
            {
                //CreateGridBoundColumns();
            }
        }

        #endregion Public Methods

        #region Events
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        #endregion Events

        #region Private Methods
        //private void CreateGridBoundColumns()
        //{
        //    if (!string.IsNullOrEmpty(lColumnCaptionHeading))
        //    {
        //        lBoundGridFields = new List<BoundField>();
        //        //BoundField lBoundField = new BoundField();

        //        string[] lStringArrayForBoundColumns = lColumnCaptionHeading.Split(';');
        //        List<UserRole> lListUserRoles = (List<UserRole>)this.gdvListGrid.DataSource;
        //        //for (int loopInt = 0; loopInt< (int)this.gdvListGrid.DataSource; loopInt++)

        //        int loopInt = 0;
        //        foreach (UserRole tempUserRole in lListUserRoles)
        //        {
        //            string[] lFieldDetails = lStringArrayForBoundColumns[loopInt].Split('|');

        //            BoundField lBoundField = new BoundField();
        //            lBoundField.DataField = tempUserRole.UserKey.ToString();
        //            BoundField.HeaderText = 

        //        }
        //    }
            //}
       
        #endregion Private Methods
        
    }
}